First, differentiate if the compiler gives you a warning or an error. A warning is not an error, it is something which can work but should better be fixed soon. An error however is always bad and should get fixed immediately. Afterwards, read what the compiler tells you. Depending on which compiler you make use of you will get more or less warning and error messages, WRECK for example makes more issues clear than the normal Native build.bat.[1] Check the last edits which you made at for the syntax, in most cases a new troop or item entry, and compare it to other working entries.
However, if your Module System compiles fine, this does not mean that your newly added scripts, triggers, etc. will also work fine! Not all errors will show up already while compiling the Module, some will appear in red on your screen when a newly added script or trigger tries to get started and fails. This can look for example like in the picture below.[2]
The error messages read as follows:
SCRIPT ERROR ON OPCODE 1677: Invalid Map Icon ID: 199; LINE NO: 25:
At script: create_kingdom_hero_party.
At script: create_kingdom_hero_party.
At script: create_kingdom_hero_party.
At script: create_kingdom_hero_party.
To resolve the issue, read the error messages backwards. To stay with the example:
So overall, the problem is that the operation party_set_banner_icon, located at 25th line of the script create_kingdom_hero_party returned 199 as a icon ID which is wrong. The icon ID should look like "icon_<icon name>", for instance "icon_camp". Now you have to look into the operations before party_set_banner_icon and find out why 199 is returned instead of a correct ID.
Again, you are able to resolve by carefully reading the error messages. The OPCODE refers to the number assigned to a given operation in header_operations.py. Search there for the number to find out which operation is causing the issue. So, if you're getting a problem with OPCODE 1, there's an issue with your usage of call_script somewhere.[3] If you are lucky it is an operation which gets less often used, otherwise you will need to start counting the lines (don't count comments or empty lines).
To give another example:[4]
Unrecognized opcode 1073741855,; LINE NO: 30:
At Mission Template mst_lead_charge trigger no: 4 consequences
how to use rgl log to debug the game, own subsection, kalarhan, Modding VC: basic tutorials and Q&A thread
compiles fine does not mean there are no bugs, kalarhan, Modding Q&A
modding practise, mark own changes, EmielRegis (credit), Modding Q&A
If not everything did go well, check carefully for spelling and syntax. Make very sure that all commas and brackets are in the right place. Bad syntax is the most common source of compiler errors in the official Module System. After compiling, errors are usually pointed out at specific lines. Using a code editor like NOTEPAD++ makes it easier as lines are numbered, and it highlights (when you mouse over one) both the beginning and ending brackets.
Since it would be useful, a little database got compiled, containing the most common errors you're likely to encounter when building the MaBL into a working mod, and their meanings.
SyntaxError: invalid syntax
Meaning: Missing a bracket, comma or quotation mark -- [], (), , or "" -- OR you have too many of them.
TypeError: 'tuple' object is not callable
Meaning: Missing a comma just before an open bracket (.
TypeError: list indices must be integers
Meaning: Missing a comma or too many brackets.
ERROR: INPUT TOKEN NOT FOUND: <name>
NameError: global name 'cause_error' is not defined
Meaning: You have a starting dialog-state -- example, [trp_guard,"guard_introduce_1", -- that isn't being led to by an ending dialog-state -- example, "close_window",[]],.
ERROR: INPUT TOKEN NOT FOUND: <empty>
NameError: global name 'cause_error' is not defined
Meaning: You have an empty starting dialog-state -- example, [trp_guard,"guard_introduce_1",.
NameError: name '<something>' is not defined
Meaning: Missing a prefix such as trp_, itm_ or mnu_ OR missing a name OR misspelled a name.
IndexError: tuple index out of range
Meaning: Nebulous. If you're modding module_mission_templates.py, look for undefined alter flags and undefined AI flags, these are the most common source.
TypeError: int argument required
Meaning: Missing an integer such as a mission template flag. You can find out which calls are integers by looking at the documentation at the beginning of each module file, (int) calls being integers.
IndexError: list index out of range
Meaning: There's an error in one of your list calls -- a list is anything between brackets.
Error: Unable to find object:<name>
ERROR: Illegal Identifier:<name>
Meaning: The object you're trying to call does not yet exist OR there is a misspelling in the name. It could also be that you forgot to put a $ or : on the variable.
WARNING: Local variable never used:<name>
Meaning: It means exactly what it says: A local variable is never used. Say you have a local variable named ":cur_day". If you declare ":cur_day" but you never ever use it in the script, it will be then a local variable which is not used.
SCRIPT WARNING ON OPCODE -<negative value>:
Meaning: A negative OPCODE means that you are using a combo like this_or_next|SOMETHING or neg|check_quest_active, etc., so find that line of code and see what you did wrong. The error tells you the trigger number, line of code, and what is wrong (invalid parameter).[5]
Not sure if this string compiler error is still present, would need to test for it.
Make sure that the files at which you use implemented constants are referencing to the respective module_*.py or headers_*.py file at which they have been declared. Alternatively you need to use directly the number of the constant, reading them out of the .py file in which they are declared. You reference .py files to each other with a line like rom module_constants import * at the top of the file. Check at the top of each module_*.py file which other ones are getting referenced already, the section Interactions between Module System Files gives you a good overview here. Keep in mind that you mostly need to reference the header files since the usage of the Module System Prefixes mentioned in Module System Prefixes do the work for you at the other module_*.py files already.
If you want to raise the attribute of a specific troop for example and do it in module_scripts.py. Intuitively you would try to use this line:
(troop_raise_attribute,"trp_player",ca_strength,-2),
Trying to compile it would however result in an error message since the compiler does not know what ca_strength stands for. Those are constants declared in header_troops.py. The situation is thus similar to the one at which you make use of a constant or variable which has not been declared yet. So you either need to use directly the number of the respective attribute (where 1=STR, 2=AGI, 3=INT and 4=CHA) as follows:
(troop_raise_attribute,"trp_player",1,-2),
or you need to add a reference line at the top of module_scripts.py as follows:
from header_troops import *
map_scene->manifold->faces[target_manifold_index].tag != rt_water (or rt_mountain)
Meaning: You have a party on the world map that is trying to spawn on water or mountain terrain. Check all your spawn points and spawn radius'.
Get Object failed for *
Meaning: Any get object failed error is where in one of your BRFs or items/scenes/scene props in-game you are referencing a texture, material or mesh that does not exist. Check the spelling and that everything is referenced properly, remember that capital letters count! Check if your resources are loading in the correct order.
Buffer.has_more_tokens()
Meaning: The message means there is a mismatch between the expected and actual size of a data structure. This could be caused by a malformed BRF, a corrupted .txt file, or a savegame incompatibility. It might also be caused by reading past the end of a data structure, e.g. you only have 25 strings and you ask for string #57. It can also be when you use a space instead of a _ in identifier names. It is a complicated error which can be caused by a variety of things.
rgl_between(skill_level,0,(skills[skill_no].max.level+1))
Meaning: This assert is checked when the game reads your skills. It verifies that the number read was not more than the possible maximum, no matter the dependent attribute (Int, Str, Dex, Cha). Typically, it means that you are either reading a skill from a nonexistent troop or reading a nonexistent skill, or both. This error can sneak up on you when you are making troops using predefined skill sets like knows_common and add additionally more skill points which let a skill exceed the maximum value.
rgl_between(current_sentence, 0, num_sentences)
Meaning: Caused when talking to someone who has nothing to say.
multiple level ups at game start, Lumos, Modding Q&A and Modding Q&A, leveling at game start problem, Lumos, Modding Q&A, Insane level up at game start, Lumos, Modding Q&A
CTD with error message : Hash Vector failed at index -100000, cmpxchg8b, Modding Q&A
hard-coded stuff not getting referenced in official MS, The_dragon, Modding Q&A
Error on last line, jacobhinds, Modding Q&A
Non ASCII charaters, reproduce error message, Antonis, Mount & Blade Modding Discord
work in notes here, Swyter, Modding Q&A
ASCII characters into Warband MP, Modding Q&A
Scandinavian characters, SupaNinjaMan and MadocComadrin, Modding Q&A
extra letters (unicode ASCI characters), kalarhan, Modding Q&A
Eventually it would make more sense to move this out to a separate World Map html. Perhaps crossreference the possible issues here and move out the rest.
World map can behave strange if separated by rivers and fords into non-connected parts, GetAssista, Modding Q&A, and again, Lumos, Modding Q&A
One can't define new ground textures, but one should be able to modify flags, meshes, colors etc of existing ones, Somebody, Modding Q&A, replace the existing ones, Dargor (credit?), Modding Q&A
Training fields, Ritter Dummbatz, Modding Q&A
Deep sea effect (find out more about it), Cozur, Modding Q&A
largest possible world map, discussion, Modding Q&A
campaign map speed, MadVader, Modding Q&A
World map stuff, Lav, Modding Q&A
Limit of vertices per mesh, cmpxchg8b, Global Map Visualiser
Some strings getting used all the time?, Somebody, Modding Q&A
hard-coded map materials, Swyter, Modding Q&A and Modding Q&A
Mixture for creating a campaign map, jacobhinds, Modding Q&A
Hard-coded material for trees, jacobhinds, Modding Q&A
world map questions, jacobhinds, Modding Q&A
Deep ocean materia? Also swamp discussion, check upfollowing page too, jacobhinds, Lav, La Grandmaster, Seek n Destroy, and Dusk Voyager, Modding Q&A
ford texture material, Michadr and produno (credit), Modding Q&A
world map inland sea maelstroem, discussion, Modding Q&A and Modding Q&A. dstn or Swyter wrote about it too, it's caused by the shader, need to fetch the notes for it.
Deep ocean, jacobhinds, Modding Q&A
ocean world map shader, La Grandmaster, Modding Q&A
world map forest performance, cmpxchg8b, Modding Q&A
Thorgrim map editor issue, MadVader, Modding Q&A
hard-coded world map terrain, The Bowman (credit?), Modding Q&A
random terrain forest problem, The Bowman, Modding Q&A
transfer changes from map editor to ms, NPC99, Modding Q&A
If own chapter, world map speed (also with K700 formula), better put to module parties section, no? kalarhan, Modding Q&A
campaign map crashes, NPC99, Modding Q&A
unanswered mountain shifts camera up, NPC99, Modding Q&A
s1 world map string, kalarhan, Modding Q&A
world map textures, NPC99, Modding Q&A
world map icons limit (crossreference to map icons, NPC99, Modding Q&A
World map with seasons, Docm30, Modding Q&A
Some sailing stuff, NPC99, Modding Q&A
ground specs, NPC99, Modding Q&A
Shore effects, NPC99, Modding Q&A
Shiny water at world map and flatter terrain, Leprechaun (credit), Useful Techniques
World map landmasses, cmpxchg8b, [WB] Warband Script Enhancer v3.2.0
Limit of vertixes per mesh at world map, cmpxchg8b, Global Map Visualiser